<?php
namespace App\Models\Rating;

use App\Models\Model;
use App\Models\System\User;

class CheckScore extends Model
{
    protected $appends = [
        'scores_detail_array'
    ];

    public function user()
    {
        return $this->belongsTo(User::class,'author_id','id');
    }

    public function check_scores_details(){
        return $this->hasMany(CheckScoresDetail::class,'ct_id','ct_id');
    }

    public function getScoresDetailArrayAttribute(){
        $scores_detail = !empty($this->attributes['scores_detail'])?$this->attributes['scores_detail']:'';
        if(!$scores_detail){
            return [];
        }
        return json_decode($scores_detail,true);
    }

}